//
//  UIBarButtonItem+Item.swift
//  PlayWithProject
//
//  Created by 陈道斌 on 2021/6/15.
//

import Foundation
import UIKit

extension UIBarButtonItem {
    
    
    
    //   class  fun
    class  func backItemWithimage(image:UIImage , highImage : UIImage  , target : UIViewController ,action :(Selector) ,title :String ) -> UIBarButtonItem {
        
        let backButton = UIButton(type: .custom)
        //  backButton.backgroundColor =[UIColor redColor];
        backButton.setTitle(title, for: UIControl.State.normal)
        backButton.setImage(image, for: .normal)
        
        backButton.setImage(highImage, for: .highlighted)
        backButton.sizeToFit()
        backButton.contentEdgeInsets = UIEdgeInsets(top: 0, left: -5, bottom: 0, right: 0);
        
        backButton.sizeToFit()
        backButton.addTarget(target, action: action, for: UIControl.Event.touchUpInside)
        
        return UIBarButtonItem(customView: backButton)
        
        
        //        [backButton setImage:image forState:UIControlStateNormal];
        //        [backButton setImage:highImage forState:UIControlStateHighlighted];
        //        [backButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        //        [backButton setTitleColor:[UIColor redColor] forState:UIControlStateHighlighted];
        //        [backButton sizeToFit];
        //        backButton.contentEdgeInsets = UIEdgeInsetsMake(0, -5, 0, 0);
        //        [backButton addTarget:target action:action forControlEvents:UIControlEventTouchUpInside];
        
    }
    
    
}
